﻿using System;
using System.Windows.Forms;
using KillBill.Business.Entities;

namespace KillBill.Presentation.Common.WindowsForms.PersonControl
{
    public partial class UscPerson : UserControl
    {
        private Person _person;

        public UscPerson()
        {
            InitializeComponent();
            _person = new Person();
        }

        public Person Person
        {
            get
            {
                _person.PersonID = TxtPersonID.Text;
                _person.FirstName = TxtFirstName.Text;
                _person.LastName = TxtLastName.Text;
                _person.Email = TxtEmail.Text;
                _person.Address = RicAddress.Text;
                _person.Phone = TxtPhone.Text;
                return _person;
            }
            set
            {
                if (value == null) return;
                TxtPersonID.Text = value.PersonID;
                TxtFirstName.Text = value.FirstName;
                TxtLastName.Text = value.LastName;
                TxtEmail.Text = value.Email;
                RicAddress.Text = value.Address;
                TxtPhone.Text = value.Phone;
                _person = value;
            }
        }

        public bool IsValid
        {
            get { return avPanel.IsValid; }
        }
    }
}
